package org.loneranger.p3_instantiation_aware.bean;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessor;
import org.springframework.stereotype.Component;


/**
 * InstantiationAwareBeanPostProcessor 是 BeanPostProcessor的子接口，可以获取bean的实例化前和实例化后
 *
 * @author shanzhenbo
 */
@Component
public class IaPostProcessor implements InstantiationAwareBeanPostProcessor {

    /**
     * 实例化前
     *
     * @param beanClass
     * @param beanName
     * @return
     * @throws BeansException
     */
    @Override
    public Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException {
        if (beanName.equals("iaService")) {
            System.out.println("实例化前");
        }
        return InstantiationAwareBeanPostProcessor.super.postProcessBeforeInstantiation(beanClass,
                beanName);
    }

}
